<?php
!function_exists('adminmsg') && exit('Forbidden');

InitGP(array('type'));
$_basename	= $basename.'&action=imagetype';
$imageTypeService = House::loadClass('houseimagetype'); /* @var $imageTypeService PW_HouseImageType */
if (!$type) {
	$topTypes = $imageTypeService->getTopTypes();
	$secendTypes = $imageTypeService->getSecendTypes();
	$ajax_basename = EncodeUrl($_basename);
	require_once PrintMode('imagetype');
} elseif ($type == 'addtype') {
	InitGP(array('sub','step'));
	define('AJAX', 1);
	if (!$step) {
		$ajax_basename = EncodeUrl($_basename);
		require_once PrintMode('ajax_image');
	} else {
		InitGP(array('position','name'));
		$result = $imageTypeService->addType($name,$sub,$position);
		if ($result) {
			echo getLangInfo('msg','operate_success')."\treload";
		} else {
			Showmsg('该名称已被使用');
		}
	}
	ajax_footer();
} elseif ($type == 'updatetypes') {
	InitGP(array('imagetype'));
	$imageTypeService->updateImageTypes($imagetype);
	adminmsg('operate_success',$_basename);
} elseif ($type == 'deltype') {
	define('AJAX', 1);
	InitGP(array('id'));
	$imageTypeService->deleteType($id);
	echo getLangInfo('msg','operate_success')."\treload";
	ajax_footer();
}
?>